import { StateType } from '@/store'
import { ComponentsStateType } from '@/store/features/componentsReducer'
import { useSelector } from 'react-redux'

const useGetComponentInfo = () => {
  const {
    componentList = [],
    selectedId,
    copiedComponent,
  } = useSelector<StateType>(state => state.components.present) as ComponentsStateType

  const selectComponent = componentList.find(c => c.fe_id === selectedId)

  return {
    componentList,
    selectedId,
    selectComponent,
    copiedComponent,
  }
}

export default useGetComponentInfo
